import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 98152
 * Date: 2024-10-15
 * Time: 20:17
 */
public class Test {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int len = in.nextInt();
        int cost[] = new int[len];
        for (int i = 0; i < len; i++) {
            cost[i] = in.nextInt();
        }
        int c0 = 0;
        for (int i = 0; i < len; i++) {
            c0 += cost[i];
            if (i < len - 2 && cost[i + 1] >= cost[i + 2]) {
                i++;
            } else if (i == len - 2) {
                i++;
            }
        }
        int c1 = 0;
        for (int i = 1; i < len; i++) {
            c1 += cost[i];
            if (i < len - 2 && cost[i + 1] >= cost[i + 2]) {
                i++;
            } else if (i == len - 2) {
                i++;
            }
        }
        int c = c0 < c1? c0:c1;
        System.out.println(c);
    }
}
